//
//  TSViewAddNavigationController.m
//  AppCommonJSCollect
//
//  Created by qian on 2023/10/23.
//  Copyright © 2023 dvlproad. All rights reserved.
//

#import "TSViewAddNavigationController.h"
#import "TSWebAddToDiffViewController.h"

@interface TSViewAddNavigationController ()<UINavigationControllerDelegate, UIGestureRecognizerDelegate>

@end

@implementation TSViewAddNavigationController

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController {
    self = [super initWithRootViewController:rootViewController];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.delegate = self;
    // 设置全屏滑动返回
    // 注意`setNavigationBarHidden:YES`设置这行代码后会导致Nav的滑动返回手势失效，
    id target = self.interactivePopGestureRecognizer.delegate;
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
    [self.view addGestureRecognizer:pan];
    self.interactivePopGestureRecognizer.enabled = NO;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}


#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断如果是需要隐藏导航控制器的类，则隐藏
    BOOL isHideNav = ([viewController isKindOfClass:[TSWebAddToDiffViewController class]]);
    
    [self setNavigationBarHidden:isHideNav animated:YES];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
